﻿<UserControl x:Class="MaxStoreShop.WarehouseModule.Characters.CharactersView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:characters="clr-namespace:MaxStoreShop.WarehouseModule.Characters"
             xmlns:converters="clr-namespace:MaxStoreErp.Core.Converters;assembly=MaxStoreErp.Core"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:directories="clr-namespace:MaxStoreShop.Domain.Directories;assembly=MaxStoreShop.Domain"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             d:DataContext="{d:DesignInstance characters:CharactersViewModel}"
             d:DesignHeight="400"
             d:DesignWidth="400"
             mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/Shared.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <converters:NullImageConverter x:Key="NullImageConverter" />
            <DataTemplate x:Key="LastNameItemTemplate">
                <Border BorderBrush="#6FBDE8" BorderThickness="0,0,0,0">
                    <TextBox Margin="0"
                             HorizontalAlignment="Stretch"
                             VerticalAlignment="Center"
                             Background="Transparent"
                             BorderThickness="0"
                             IsReadOnly="True"
                             Text="{Binding LastName}"
                             d:DataContext="{d:DesignInstance directories:Character}" />
                </Border>
            </DataTemplate>
            <DataTemplate x:Key="FirstNameItemTemplate">
                <Border BorderBrush="#6FBDE8" BorderThickness="0,0,0,0">
                    <TextBox Margin="0"
                             HorizontalAlignment="Stretch"
                             VerticalAlignment="Center"
                             Background="Transparent"
                             BorderThickness="0"
                             IsReadOnly="True"
                             Text="{Binding FirstName}"
                             d:DataContext="{d:DesignInstance directories:Character}" />
                </Border>
            </DataTemplate>
            <DataTemplate x:Key="MiddleNameItemTemplate">
                <Border BorderBrush="#6FBDE8" BorderThickness="0,0,0,0">
                    <TextBox Margin="0"
                             HorizontalAlignment="Stretch"
                             VerticalAlignment="Center"
                             Background="Transparent"
                             BorderThickness="0"
                             IsReadOnly="True"
                             Text="{Binding MiddleName}"
                             d:DataContext="{d:DesignInstance directories:Character}" />
                </Border>
            </DataTemplate>
            <DataTemplate x:Key="PhoneItemTemplate">
                <Border BorderBrush="#6FBDE8" BorderThickness="0,0,0,0">
                    <TextBox Margin="0"
                             HorizontalAlignment="Stretch"
                             VerticalAlignment="Center"
                             Background="Transparent"
                             BorderThickness="0"
                             IsReadOnly="True"
                             Text="{Binding Phone}"
                             d:DataContext="{d:DesignInstance directories:Character}" />
                </Border>
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <ListView Name="MainListView"
                  ItemsSource="{Binding ViewerData}"
                  SelectedItem="{Binding SelectedItem,
                                         Mode=TwoWay}"
                  SelectionMode="Single">
            <ListView.View>
                <GridView d:DataContext="{d:DesignInstance directories:Character}">
                    <GridView.Columns>
                        <GridViewColumn CellTemplate="{StaticResource LastNameItemTemplate}" Header="Фамилия" />
                        <GridViewColumn CellTemplate="{StaticResource FirstNameItemTemplate}" Header="Имя" />
                        <GridViewColumn CellTemplate="{StaticResource MiddleNameItemTemplate}" Header="Отчество" />
                        <GridViewColumn CellTemplate="{StaticResource PhoneItemTemplate}" Header="Телефон" />
                        <GridViewColumn CellTemplate="{StaticResource EditColumnItemTemplate}" />
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>

        <TabControl Grid.Row="1">
            <TabItem Header="Подробные сведения">
                <Border CornerRadius="3">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                            <GradientStop Color="#FF494949" />
                            <GradientStop Offset="1" Color="#FF333333" />
                        </LinearGradientBrush>
                    </Border.Background>
                    <Grid Height="Auto">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Grid Margin="20"
                              HorizontalAlignment="Left"
                              VerticalAlignment="Center"
                              Background="White"
                              d:LayoutOverrides="GridBox">
                            <StackPanel Background="#FF929191" Orientation="Vertical">
                                <Border Margin="6,6,6,6"
                                        BorderBrush="Bisque"
                                        BorderThickness="1"
                                        CornerRadius="6"
                                        UseLayoutRounding="True">
                                    <Image MinWidth="100"
                                           MinHeight="100"
                                           MaxWidth="100"
                                           Margin="1"
                                           DataContext="{Binding SelectedItem}"
                                           Source="{Binding Photo,
                                                            Converter={StaticResource NullImageConverter}}" />
                                </Border>
                            </StackPanel>
                        </Grid>

                        <Grid Grid.Row="0"
                              Grid.Column="1"
                              HorizontalAlignment="Left"
                              VerticalAlignment="Top"
                              DataContext="{Binding SelectedItem}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="120" />
                            </Grid.RowDefinitions>
                            <StackPanel Grid.ColumnSpan="2" Orientation="Horizontal">
                                <TextBlock Margin="0,0,3,0"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Center"
                                           FontFamily="Segoe UI"
                                           FontSize="20"
                                           Foreground="#FFFFFFFF"
                                           Text="{Binding LastName}"
                                           d:DataContext="{d:DesignInstance directories:Character}" />
                                <TextBlock Margin="3,0,3,0"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Center"
                                           FontFamily="Segoe UI"
                                           FontSize="20"
                                           Foreground="#FFFFFFFF"
                                           Text="{Binding FirstName}"
                                           d:DataContext="{d:DesignInstance directories:Character}" />
                                <TextBlock Margin="3,0,0,0"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Center"
                                           FontFamily="Segoe UI"
                                           FontSize="20"
                                           Foreground="#FFFFFFFF"
                                           Text="{Binding MiddleName}"
                                           d:DataContext="{d:DesignInstance directories:Character}" />
                            </StackPanel>

                            <TextBlock Grid.Row="1"
                                       Grid.Column="0"
                                       Margin="0,0,5,0"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Center"
                                       Foreground="White"
                                       Opacity="0.5"
                                       Text="Место жительства"
                                       TextWrapping="Wrap" />
                            <TextBlock Grid.Row="2"
                                       Grid.Column="0"
                                       Margin="0,0,5,0"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Top"
                                       Foreground="White"
                                       Opacity="0.5"
                                       Text="Примечание"
                                       TextWrapping="Wrap" />
                            <TextBox Name="ResidencePlaceTextBox"
                                     Grid.Row="1"
                                     Grid.Column="1"
                                     Margin="5"
                                     Background="Transparent"
                                     BorderBrush="Gray"
                                     Foreground="White"
                                     IsReadOnly="True"
                                     TabIndex="2"
                                     Text="{Binding PlaceOfResidence,
                                                    UpdateSourceTrigger=PropertyChanged}" />
                            <xctk:RichTextBox x:Name="NoteRichTextBox"
                                              Grid.Row="2"
                                              Grid.Column="1"
                                              Margin="5"
                                              HorizontalAlignment="Left"
                                              Background="Transparent"
                                              BorderBrush="Gray"
                                              FlowDirection="LeftToRight"
                                              Foreground="White"
                                              IsReadOnly="True"
                                              Opacity="0.5"
                                              TabIndex="3"
                                              Text="{Binding Note,
                                                             UpdateSourceTrigger=PropertyChanged}">
                                <xctk:RichTextBox.Document>
                                    <FlowDocument PageWidth="{Binding ElementName=NoteRichTextBox, Path=ActualWidth}" />
                                </xctk:RichTextBox.Document>
                            </xctk:RichTextBox>
                        </Grid>
                    </Grid>
                </Border>
            </TabItem>
        </TabControl>
        <ToolBar Name="MainToolBar"
                 Grid.Row="2"
                 Visibility="Collapsed">
            <Button Width="44"
                    Height="44"
                    BorderThickness="0"
                    Command="{Binding AddNewItemCommand}"
                    IsDefault="True"
                    Style="{DynamicResource MetroCircleButtonStyle}"
                    ToolTip="Добавить пользователя">
                <Path Width="32"
                      Height="32"
                      Data="{StaticResource AddIcon}"
                      Fill="{DynamicResource BlackBrush}"
                      Stretch="Uniform" />
            </Button>
        </ToolBar>
    </Grid>
</UserControl>
